package com.yly.input.demo.converter;

import com.yly.input.demo.bo.ElderBO;
import com.yly.input.demo.vo.ElderVO;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * 返回给客户端数据转换 BO -> VO
 */
@Service
public class ServiceConverter {

  public List<ElderVO> toElderVO(List<ElderBO> boList) {
    if (boList == null || boList.isEmpty()) {
      return null;
    }

    List<ElderVO> voList = new ArrayList<>();
    for (ElderBO bo : boList) {
      ElderVO vo = new ElderVO();
      BeanUtils.copyProperties(bo, vo);
      voList.add(vo);
    }
    return voList;
  }
}
